<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport"
          content="width=device-width, initial-scale=0.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"/>
    <meta name="keywords" content=""/>
    <meta name="description" content="">
    <meta name="author" content=""/>
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="black" name="apple-mobile-web-app-status-bar-style">
    <meta content="telephone=no" name="format-detection">
    <link rel="stylesheet" type="text/css" href="/assets/css/public.css">
    <title>文章详情</title>
    <script src="/assets/js/jquery-1.8.0.min.js"></script>
    <script src="/assets/js/hjk.js"></script>
    <link rel="stylesheet" type="text/css" href="/assets/css/GXQ.css"/>
    <script type="text/javascript">
    	$(document).ready(function(){
    		$(".g06_bt").click(function(){
    			var content = $(".g06_tt").val();
    			var artId = $("#artId").val();
    			if(content == ""){
    				alert("评论内容不能为空");
    			}else{
        			var isLoginUrl = "/user/login/isLogin";
        			$.post(
        					isLoginUrl,
        					function(data){
        						if(data == 1){
        							var addCommentUrl = "/article/add";
        							$.post(
        									addCommentUrl,
        									{commentContent:content,articleId:artId},
        									function(data){
        										if(data == 1){
        											window.location.reload();
        										}else{
        											if(confirm("您未登录无法评论，是否前往登录？")){
        			    								window.location.href = "/user/login";
        			    							}
        										}
        									}
        							);
        						}else{
        							if(confirm("您未登录无法评论，是否前往登录？")){
        								window.location.href = "/user/login";
        							}
        						}
        					}
        			);
    			}
    			
    		});
    	});
    
    	function collection(id){
    		var url = "/collection/add";
    		$.post(
    			url,
    			{articleid:id},
    			function(data){
    				if(data == 0){
    					alert("您尚未登录");
    				}else{
    					if(data == 2){
    						alert("您已收藏了该文章");
    					}else{
    						alert("收藏成功");
    					}
    				}
    			}
    		);
    	}
    </script>
</head>

<body class="g05">
<!--隐藏部分-->
	<div class="g05_yy"></div>
    <header class="g_header_05">    	
        <a href="/"><span class="k_hBack"></span></a>${a.tittle }
        <div class="g05_image2_show" onclick="collection(${a.id})"></div> 
    </header>   
    
    
    <article class="g05_a">
    	<div class="g05_a1">
        	<img class="g05_image4" src="/assets/images/g_zjtd_05.png" />
        	<span class="g05_span1">${a.author }</span>
            <span class="g05_span2"> &nbsp;楼主&nbsp; </span>
        </div>
        <div class="g05_wz">
        	<p class="g05_p1"><span>${a.otherTittle }</span></p>
            <p class="g05_p2"><span>创建于${a.createTime }</span></p>
            ${a.content }
        </div>
        
        <c:forEach var="articleCommentDto" items="${articleCommentDtoList }">
        <div class="g05_pl clearfix">
        	<div class="g06_image">
        	<img src="${articleCommentDto.headPath }" />
        </div>
        <div class="g06_al">
        	<p class="g06_p g06_p1"><span>${articleCommentDto.nickName }</span></p>
            <p class="g06_p g06_p2"><span>${articleCommentDto.createTime }</span></p>
            <p class="g06_p g06_p3"><span>${articleCommentDto.commentContent }</span></p>
        </div>
        </c:forEach>

		<div class="g05_pl clearfix">
        	<div class="g06_image">
        </div>
        <div class="g06_al">
        </div>
    </article>
    
    <footer class="g06_footer">
        <input class="g06_tt" name="text" type="text" placeholder="来说点什么吧" value=""/>
        <input id="artId" type="hidden" value="${a.id }">
        <input class="g06_bt" name="button" type="button" value="发送" />
    </footer>
    
</body>
</html>
